
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
@react-leaflet/core
Advanced tools
@react-leaflet/core is a core library for integrating Leaflet maps with React. It provides a set of hooks and components that allow developers to create interactive maps with ease, leveraging the power of React's declarative approach.
Map Container
This feature allows you to create a map container and add a tile layer to it. The MapContainer component initializes the map, and the TileLayer component adds the map tiles from OpenStreetMap.
import { MapContainer, TileLayer } from '@react-leaflet/core';
function MyMap() {
return (
<MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
/>
</MapContainer>
);
}
Markers
This feature allows you to add markers to the map. The Marker component places a marker at the specified position, and the Popup component displays a popup when the marker is clicked.
import { MapContainer, TileLayer, Marker, Popup } from '@react-leaflet/core';
function MyMap() {
return (
<MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
/>
<Marker position={[51.505, -0.09]}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker>
</MapContainer>
);
}
Polylines
This feature allows you to draw polylines on the map. The Polyline component takes an array of latitude and longitude pairs and draws a line connecting them.
import { MapContainer, TileLayer, Polyline } from '@react-leaflet/core';
function MyMap() {
const polyline = [
[51.505, -0.09],
[51.51, -0.1],
[51.51, -0.12]
];
return (
<MapContainer center={[51.505, -0.09]} zoom={13} style={{ height: '100vh', width: '100%' }}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
/>
<Polyline positions={polyline} />
</MapContainer>
);
}
react-leaflet is a popular library that provides React components for Leaflet maps. It offers a higher-level API compared to @react-leaflet/core, making it easier to use for common tasks. However, @react-leaflet/core provides more flexibility and control for advanced use cases.
leaflet is the core JavaScript library for interactive maps. It is not specific to React and can be used with any JavaScript framework or vanilla JavaScript. @react-leaflet/core builds on top of leaflet to provide a React-friendly API.
react-map-gl is a React wrapper for Mapbox GL JS, which provides interactive maps with WebGL. It offers similar functionalities to @react-leaflet/core but is based on Mapbox instead of Leaflet. It is suitable for applications that require high-performance rendering and advanced map features.
FAQs
React Leaflet core
The npm package @react-leaflet/core receives a total of 397,562 weekly downloads. As such, @react-leaflet/core popularity was classified as popular.
We found that @react-leaflet/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.